package com.study.queue;


import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * Created By gtx on 2017/8/12/9:47
 */
public class CuratorClientFactory {
    //mic老师专用
//    private final static String CONNECTSTRING="192.168.11.129:2181,192.168.11.134:2181," +
//            "192.168.11.135:2181,192.168.11.136:2181";

    private final static String CONNECTSTRING="192.168.254.135:2181,192.168.254.136:2181,"
            +"192.168.254.137:2181,192.168.254.138:2181";

    /**根节点*/
    public static final String QUEUE_NODE="/curatorQueue";

    public static final int SESSION_TIME_OUT=5000;

    public static final int CONNECTION_TIME_OUT=5000;

    public static CuratorFramework getInstance(){
        CuratorFramework curatorFrameworkt= CuratorFrameworkFactory.builder().connectString(CONNECTSTRING).
                connectionTimeoutMs(CONNECTION_TIME_OUT).sessionTimeoutMs(SESSION_TIME_OUT)
                .retryPolicy(new ExponentialBackoffRetry(1000,3))
                .build();
        curatorFrameworkt.start();

        return curatorFrameworkt;
    }
}
